//
//  HJDTabBarController.m
//  JYHospital
//
//  Created by 胡金东 on 16/3/31.
//  Copyright © 2016年 胡金东. All rights reserved.
//

#import "HJDTabBarController.h"
#import "HJDPofileControllerr.h"
#import "HJDHomeController.h"
#import "HJDBBSController.h"
#import "HJDTabBar.h"
#import "HJDNavigationController.h"
#import "HJDHospitalViewController.h"



//#import "UIColor+BaseColor.h"



@interface HJDTabBarController ()

@end

@implementation HJDTabBarController

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //自定义tabBar
    HJDTabBar *tabBar = [[HJDTabBar alloc]initWithFrame:self.tabBar.frame];
    //利用KVC把readly的属性改掉
    [self setValue:tabBar forKeyPath:@"tabBar"];
    
    [self setUpViewController];
}

-(void)setUpViewController
{
    
    // 首页
    HJDHomeController *home = [[HJDHomeController alloc]init];
    [self setUpOneChildViewController:home image:[UIImage imageNamed:@"tabbar_profile"] selectedImage:[UIImage imageWithOriginalName:@"tabbar_profile_selected"] title:@"首页"];
//    home.view.backgroundColor = [UIColor purpleColor];
    
    
//我的
//    HJDPofileControllerr *home = [[HJDPofileControllerr alloc]init];
//    [self setUpOneChildViewController:home image:[UIImage imageNamed:@"tabbar_home"] selectedImage:[UIImage imageWithOriginalName:@"tabbar_home_selected"] title:@"我的"];
//    home.view.backgroundColor = [UIColor lightGrayColor];
//    home.view.backgroundColor = [UIColor getColorWithHexNumber:@"F3F3F3"];
//    home.view.backgroundColor = HJDBACKCOLOR;
//论坛
    HJDBBSController *pofile = [[HJDBBSController alloc]init];
    [self setUpOneChildViewController:pofile image:[UIImage imageNamed:@"tabbar_message_center"] selectedImage:[UIImage imageWithOriginalName:@"tabbar_message_center_selected"] title:@"论坛"];
//    pofile.view.backgroundColor = [UIColor yellowColor];
// 医院
    HJDHospitalViewController *hospital = [[HJDHospitalViewController alloc]init];
    [self setUpOneChildViewController:hospital image:[UIImage imageNamed:@"tabbar_home"] selectedImage:[UIImage imageWithOriginalName:@"tabbar_home_selected" ]title:@"医院"];
    
}
//抽出相同的，在-(void)setUpViewController进行调用就行
-(void)setUpOneChildViewController:(UIViewController *)vc image:(UIImage *)image selectedImage:(UIImage *)selectedImage title:(NSString *)title
{//可以同时设置tabBar和导航文字
    vc.title = title;
    vc.tabBarItem.image = image;
    NSMutableDictionary *dic = [NSMutableDictionary dictionary];
    [dic setObject:[UIColor getColorWithHexNumber:@"5CC6AB"] forKey:NSForegroundColorAttributeName];
    
    
    [vc.tabBarItem setTitleTextAttributes:dic forState:UIControlStateSelected];
    vc.tabBarItem.selectedImage = selectedImage;
//    HJDNavigationController *nav = [[HJDNavigationController alloc]initWithRootViewController:vc];
    [self addChildViewController:vc ];
    
    
}


@end
